<!DOCTYPE html>
<html lang="zh-CN">
<!-- jasmine 学习  https://jasmine.github.io/2.3/introduction.html 用法 -->
<head>
    <meta charset="utf-8">
    <meta name=”Keywords” Content=”火星翻译″>
    <meta name=”Description” Content=”你网页的简述”>
    <title>Document</title>
    <!-- import css -->
    <!-- <link href="star.css" rel="stylesheet" type="text/css" /> -->
    <link rel="shortcut icon" type="image/png" href="F:/js/jstest/js/jasmine-2.8.0/jasmine_favicon.png">
    <link rel="stylesheet" type="text/css" href="F:/js/jstest/js/jasmine-2.8.0/jasmine.css">
    <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="F:/js/jstest/js/jasmine-2.8.0/jasmine.js"></script>
    <script type="text/javascript" src="F:/js/jstest/js/jasmine-2.8.0/jasmine-html.js"></script>
    <script type="text/javascript" src="F:/js/jstest/js/jasmine-2.8.0/boot.js"></script>
</head>

<body>
    <div class="container" id="container">
        <ul class="ulitems">
            <li class="liitem">1</li>
            <li class="liitem">2</li>
            <li class="liitem">3</li>
            <li class="liitem">4</li>
            <li class="liitem">5</li>
        </ul>
    </div>
</body>
<script type="text/javascript">
	
describe("A Group", function() {
    it("item1", function() {
        expect(true).toBe(true);
    });

    it("item2", function() {
        expect(!!"true").toBe(true);
    });

});
describe("Included matchers:", function() {

    it("The 'toBe' matcher compares with ===", function() {
        var a = 12;
        var b = a;

        expect(a).toBe(b);
        expect(a).not.toBe(null);
    });

    describe("The 'toEqual' matcher", function() {

        it("works for simple literals and variables", function() {
            var a = 12;
            expect(a).toEqual(12);
        });

        it("should work for objects", function() {
            var foo = {
                a: 12,
                b: 34
            };
            var bar = {
                a: 12,
                b: 34
            };
            expect(foo).toEqual(bar);
        });
    });

    it("The 'toMatch' matcher is for regular expressions", function() {
        var message = "foo bar baz";

        expect(message).toMatch(/bar/);
        expect(message).toMatch("bar");
        expect(message).not.toMatch(/quux/);
    });

    it("The 'toBeDefined' matcher compares against `undefined`", function() {
        var a = {
            foo: "foo"
        };

        expect(a.foo).toBeDefined();
        expect(a.bar).not.toBeDefined();
    });

    it("The `toBeUndefined` matcher compares against `undefined`", function() {
        var a = {
            foo: "foo"
        };

        expect(a.foo).not.toBeUndefined();
        expect(a.bar).toBeUndefined();
    });

    it("The 'toBeNull' matcher compares against null", function() {
        var a = null;
        var foo = "foo";

        expect(null).toBeNull();
        expect(a).toBeNull();
        expect(foo).not.toBeNull();
    });

    it("The 'toBeTruthy' matcher is for boolean casting testing", function() {
        var a, foo = "foo";

        expect(foo).toBeTruthy();
        expect(a).not.toBeTruthy();
    });

    it("The 'toBeFalsy' matcher is for boolean casting testing", function() {
        var a, foo = "foo";

        expect(a).toBeFalsy();
        expect(foo).not.toBeFalsy();
    });

    describe("The 'toContain' matcher", function() {
        it("works for finding an item in an Array", function() {
            var a = ["foo", "bar", "baz"];

            expect(a).toContain("bar");
            expect(a).not.toContain("quux");
        });

        it("also works for finding a substring", function() {
            var a = "foo bar baz";

            expect(a).toContain("bar");
            expect(a).not.toContain("quux");
        });
    });

    it("The 'toBeLessThan' matcher is for mathematical comparisons", function() {
        var pi = 3.1415926,
            e = 2.78;

        expect(e).toBeLessThan(pi);
        expect(pi).not.toBeLessThan(e);
    });

    it("The 'toBeGreaterThan' matcher is for mathematical comparisons", function() {
        var pi = 3.1415926,
            e = 2.78;

        expect(pi).toBeGreaterThan(e);
        expect(e).not.toBeGreaterThan(pi);
    });

    it("The 'toBeCloseTo' matcher is for precision math comparison", function() {
        var pi = 3.1415926,
            e = 2.78;

        expect(pi).not.toBeCloseTo(e, 2);
        expect(pi).toBeCloseTo(e, 0);
    });

    it("The 'toThrow' matcher is for testing if a function throws an exception", function() {
        var foo = function() {
            return 1 + 2;
        };
        var bar = function() {
            return a + 1;
        };
        var baz = function() {
            throw 'what';
        };

        expect(foo).not.toThrow();
        expect(bar).toThrow();
        expect(baz).toThrow('what');
    });

    it("The 'toThrowError' matcher is for testing a specific thrown exception", function() {
        var foo = function() {
            throw new TypeError("foo bar baz");
        };

        expect(foo).toThrowError("foo bar baz");
        expect(foo).toThrowError(/bar/);
        expect(foo).toThrowError(TypeError);
        expect(foo).toThrowError(TypeError, "foo bar baz");
    });
});

describe("A spec using the fail function", function() {
    var foo = function(x, callBack) {
        if (x) {
            callBack();
        }
    };

    it("should not call the callBack", function() {
        foo(false, function() {
            fail("Callback has been called");
        });
    });
});
</script>

</html>